var express = require('express');
var router = express.Router();
var  EmployeePerformanceModel  = require('../db/EmployeePerformance');
/* GET users listing. */
router.get('/list',async function(req, res, next) {
    let list = await EmployeePerformanceModel.find({});
    console.log(list);
    res.json({
      code:200,
      data:list
    });
});
router.post('/deleteAll',async function(req, res, next) {
    let ids=req.body.ids;
    await EmployeePerformanceModel.deleteMany({_id:ids})
    res.json({
        code:200,
        msg:'删除成功'
    })
});
router.post('/add',async function(req, res, next) {
    let data=req.body;
    await EmployeePerformanceModel.create(data)
    res.json({
        code:200,
        msg:'添加成功'
    })
});
router.post('/update',async function(req, res, next) {
    let data=req.body;
    await EmployeePerformanceModel.updateOne({_id:data._id},data)
    res.json({
        code:200,
        msg:'修改成功'
    })
});
module.exports = router;